'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {
    // Org: {
    //     type: Schema.ObjectId,
    //     Name: '组织',
    //     ref: 'Org'        
    // },
    Department: {
        type: Schema.ObjectId,
        Name: '部门',
        ref: 'Department'
    },
    Operation: {
	    type: Schema.ObjectId,
	    ref: 'Operation',
	    Name: '质检工序'
	},
    Work: {
	    type: Schema.ObjectId,
	    ref: 'Work',
	    Name: '作业'
	},	
    BizDate: {
	    type: Date,
	    Name: '流水日期',
	    IsEmpty: false
	},
	BadType: {
	    type: Number,
	    Name: '缺陷类型'
	},
	Qty: {
	    type: Number,
	    Name: '数量',
	    default: 0
	}
};

var newModel = new Model(modelField);
newModel.addIndex({Department: 1, Operation: 1, BizDate: 1, BadType: 1}, {"unique": true});
newModel.create('QCBadType', '质检缺陷类型分布');